import { AnyAction } from 'redux';
import { ConfState } from '@/redux/interface';
import produce from 'immer';
import * as types from '@/redux/mutation-types';

const confState: ConfState = {
	prev_key: 'ArrowLeft',
	next_key: 'ArrowRight',
	init_key: 'Escape',
	split_key: 'Enter',
	linner_key: ' ',
	message_linner_key: 'q',
	linner_press_down: true,
	bg_url: '',
};

// conf reducer
const conf = (state: ConfState = confState, action: AnyAction) =>
	produce(state, (draftState) => {
		switch (action.type) {
			case 'SET_CONF':
				console.log(action.setobj);
				Object.assign(draftState, action.setobj);
				break;
			default:
				return draftState;
		}
	});

export default conf;
